package engine.newUi
{
	import engine.data.BindManage;
	import engine.data.ModelLocator;
	import engine.data.ResPath;
	import engine.logic.LogSendLogic;
	import engine.net.event.CustomMsgEvent;
	import engine.net.messages.CustomToClientFlag;
	import engine.net.messages.CustomToServerFlag;
	import engine.net.mgr.SystemSender;
	import engine.tip.TipsMainLogic;
	import engine.ui.AlertUI;
	
	import flash.display.DisplayObjectContainer;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	import newx.com.config.StaticIni;
	import newx.com.control.window.NxWindow;
	import newx.com.control.window.NxWindowEvent;
	
	/**
	 * 帮派活动——帮派仙宴
	 * @author yangyuechao
	 */
	public class FamilyDinnerLogic
	{
		private static var _self:FamilyDinnerLogic
		
		private var _myDis:FamilyDinnerUI;
		private var _model:ModelLocator;
		
		private var _timer:Timer;
		private var _width:int;
		
		public function FamilyDinnerLogic()
		{
			_model				=	ModelLocator.getInstance();
			_myDis				=	FamilyDinnerUI.getInstance();
		}
		public static function getInstance():FamilyDinnerLogic
		{
			if(_self == null)
			{
				_self = new FamilyDinnerLogic();
			}
			return _self;
		}
		/**
		 * 开始监听
		 */		
		public function addListener():void
		{
			fullLoading();
		}
		/**
		 * 移除监听
		 */		
		public function removeListener():void
		{
			
		}
		
		/**
		 * loading
		 */
		private function fullLoading():void
		{
			_timer = new Timer(100, 100);
			_timer.addEventListener(TimerEvent.TIMER, timerHandler);
			_timer.addEventListener(TimerEvent.TIMER_COMPLETE, timerCompleteHandler);
			_timer.start();
		}
		
		private function timerHandler(t:TimerEvent):void
		{
			if(_width > 100) return;
			_width ++;
			_myDis.loading.bar = _width;
			if(FamilyDinnerUI.getInstance().created == false){
				_timer.stop();
				_width = 0;
				_myDis.loading.bar = _width;
			}
		}
		
		private function timerCompleteHandler(t:TimerEvent):void
		{
			_timer.stop();
			_width = 0;
			_myDis.loading.bar = _width;
			//发送消息
			if(_myDis){
				_myDis.hide();
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_ON_SELECT_GUILD_DINNER);
			}
		}
	}
}